﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using NetworkCommsDotNet;
using System.Net;

namespace SimpleOnlineGame_Client
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This is the client.");

            NetworkComms.AppendGlobalIncomingPacketHandler<string>("Message", delegate
                (PacketHeader header, Connection connection, string message)
            {
                Console.WriteLine("\nA message received from " + connection.ToString());
                Console.WriteLine("Message: " + message);
                
            });

            while (true)
            {
                string input = Console.ReadLine();
                string[] data = input.Split(' ');

                switch (data[0])
                {
                    case "/exit":

                        return;

                    case "/send":

                        UDPConnection.SendObject("Message", data[1], new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7777));
                        break;
                }
            }
        }
    }
}
